home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / stv.lha / STV / st_v / S7VMac10 / remove.m1x < prev    next >
Text File  |  1993-07-23  |  897b  |  32 lines

  1. Fixes to OrderedCollection>>remove:ifAbsent: and >>removeIndex:
  2. problem in VMAC 1.0 1.1 1.2
  3. ==================================================================
  4.  
  5. ! OrderedCollection methods !
  6.  
  7. remove: anObject ifAbsent: aBlock
  8.     1 to: self size do: [ :i |
  9.         anObject = (self at: i)
  10.             ifTrue: [
  11.                 self removeIndex: i.
  12.                 ^anObject]].
  13.     ^aBlock value !
  14.  
  15.  
  16. removeIndex: anInteger
  17.     "Answer the receiver. Remove the element of the receiver at index
  18.     position anInteger."
  19.     | index |
  20.  
  21.     index := anInteger + startPosition - 1.
  22.     (index between: startPosition and: endPosition)
  23.         ifFalse: [^self errorAbsentElement].
  24.     [index < endPosition]
  25.         whileTrue: [
  26.             contents
  27.                 at: index
  28.                 put: (contents at: index + 1).
  29.             index := index + 1].
  30.     contents at: endPosition put: nil.
  31.     endPosition := endPosition - 1. ! !
  32.